package com.jinxin.platform.cdfaceacs.controller;

import com.jinxin.platform.base.common.pojo.JsonResult;
import com.jinxin.platform.cdfaceacs.pojo.form.AppMonthForm;
import com.jinxin.platform.cdfaceacs.pojo.form.AppPageForm;
import com.jinxin.platform.cdfaceacs.service.CdattendancerecordRecordService;
import com.jinxin.platform.cdfaceacs.utils.ValidationUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Date: 2021-04-23
 * Author: yangjie
 * desc:
 **/
@Api(tags = "app接口")
@RestController
@RequestMapping(value = "/attendanceRecord/app")
public class AppController {
    @Resource
    CdattendancerecordRecordService recordService;

    @ApiOperation(value = "考勤记录列表")
    @PostMapping(value = "/pageRecordList")
    public JsonResult pageRecordList(@RequestBody @Validated AppPageForm pageForm) {
        ValidationUtils.validate(pageForm);
        return JsonResult.ok(recordService.appPageRecordList(pageForm));
    }

    @ApiOperation(value = "获取月份考勤记录")
    @PostMapping(value = "/getByMonth")
    public JsonResult getByMonth(@RequestBody @Validated AppMonthForm monthForm) {
        ValidationUtils.validate(monthForm);
        return JsonResult.ok(recordService.getByMonth(monthForm));
    }

    @ApiOperation(value = "统计考勤记录各种状态的人数")
    @GetMapping(value = "/countByClockStatus")
    public JsonResult countByClockStatus() {
        return JsonResult.ok(recordService.countByClockStatus());
    }
}
